<?php
$isReloadable = false;
require_once "../../../pers/inc.config.php";
require_once OVF_FS_WEB_ROOT.'/app/_inc/inc.session.php';
require_once OVF_FS_WEB_ROOT.'/app/_inc/funct.html.php';
require_once OVF_FS_WEB_ROOT.'/app/_inc/class.ovfForm.php';

$oForm = new ovfForm('campagne');

if (reqVar('azione') == 'salva') {
	$msgPag = conferma();
} 

if (reqVar('azione') == '') {
	$oForm->setDef();
}
$oForm->preForm();

$sCmdR = "";
$sCmdR .= "<a class=\"cmd1\" href=\"javascript:document.frm1.submit();\" >salva</a>\n";
$sCmdR .= cmdTorna();

testaHtml('Campagne','Nuova campagna',$msgPag,'rcom');
?>
<table border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="right">
			<? echo  $sCmdR;?>
      </td>
   </tr>
</table>
<?=getHtmlForm('frm1','',array('enctype'=>true));?>
<?=getHtmlHidden('azione','salva');?>
<?=getHtmlHidden('xsn',XSN);?>
<table class="tab1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
	<?=getHtmlRigaRif();?>
   <tr>
      <td class="tit1" colspan='20' align='center'>Campagna</td>
   </tr>
<?
echo $oForm->getHtmlCampiForm();
?>
</table>
<table border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="right">
         <? echo  $sCmdR;?>
      </td>
   </tr>
</table>
<?
echo "</form>\n";
codaHtml();
exit();
function conferma() {
	global $objDB, $objSess, $oForm;
	$msg = '';
	//dbg_($oForm);
	$msg .= $oForm->formCheck();
	
	if ($msg != '') {
		return $msg;
	}
	$oForm->form2db();
	
	$sSql = $oForm->getInsertDb("ovf_campagne");
	$objDB->exec($sSql);
	
	header("Location: ".urlTorna("campagna inserita"));
	exit();
}
